home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / MEMCPY.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  45 lines

  1.  
  2. /*  File   : memcpy.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 25 May 1984
  5.     Defines: memcpy()
  6.  
  7.     memcpy(dst, src, len)
  8.     moves len bytes from src to dst.  The result is dst.  This is not
  9.     the same as strncpy or strnmov, while move a maximum of len bytes
  10.     and stop early if they hit a NUL character.  This moves len bytes
  11.     exactly, no more, no less.  See also bcopy() and bmove() which do
  12.     not return a value but otherwise do the same job.
  13.  
  14.     Note: the VAX assembly code version can only handle 0 <= len < 2^16.
  15.     It is presented for your interest and amusement.
  16. */
  17.  
  18. #include "strings.h"
  19.  
  20. #if     VaxAsm
  21.  
  22. char *memcpy(dst, src, len)
  23.     char *dst, *src;
  24.     int len;
  25.     {
  26.         asm("movc3 12(ap),*8(ap),*4(ap)");
  27.         return dst;
  28.     }
  29.  
  30. #else  ~VaxAsm
  31.  
  32. char *memcpy(dst, src, len)
  33.     char *dst;
  34.     register char *src;
  35.     register int len;
  36.     {
  37.         register char *d;
  38.  
  39.         for (d = dst; --len >= 0; *d++ = *src++) ;
  40.         return dst;
  41.     }
  42.  
  43. #endif  VaxAsm
  44.  
  45.